package wsl.parse;

import static wsl.tool.PrintTool.output;

import java.util.List;

public class PlantHandler {
	
	
	public void getPriceList(List<Plant> list){
		for(Plant p: list){
			output(p.getCommon()+ ":"+p.getPrice());
		}
	}
	public double getMaxPrice(List<Plant> list){
		double max = Double.MIN_VALUE;
		String plantName="";
		for(Plant p: list){
			if(p.getPrice() > max){
				max = p.getPrice();
				plantName = p.getCommon();
			}
		}
		return max;
	}
	public Plant getMinPrice(List<Plant> list){
		double min=Double.MAX_VALUE;
		Plant selectPlant = new Plant();
		//int index=0;
		for(Plant p:list){
			if(p.getPrice()<min){
				min=p.getPrice();
				selectPlant = p;
			}
			//index++;
		}
		return selectPlant;
	}
	public double getAveragePrice(List<Plant> list){
		double sum=0;
		for(Plant p:list){
			sum+=p.getPrice();
		}
		double average=0;
		average=sum/list.size();
		return average;
	}
}
